/**
 * Created by zhangyilin on 2018/11/21.
 */
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;



/**
 * Servlet implementation class createTask
 *
 * 创建任务操作
 */
@WebServlet("/createTask")
public class createTask extends HttpServlet{
    public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        String taskTheme = request.getParameter("taskTheme");//任务主题
        String taskDeadline = request.getParameter("taskDeadline");//任务截止日期
        String taskContent = request.getParameter("taskContent").replaceAll("\r\n", "");//任务详细内容
//        System.out.println(taskContent);
        String taskGroup = request.getParameter("inviteID");//测试，正式时taskGroup因点击班级再创建任务，后台自动获取该班级邀请码
        String[] taskContents = taskContent.split(";");
        StringBuilder taskBuilder = new StringBuilder().append("");
        for (int i = 0; i < taskContents.length; i++) {
            taskBuilder.append(taskContents[i]+"@N"+";");
        }
        taskContent = taskBuilder.toString();
        Task task = new Task(taskTheme, taskDeadline, taskGroup,taskContent);
        out.print(task.toString());
    }


}